// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import util from 'util'
import io from 'api/io'

  // import Vconsole from 'vconsole'
  // new Vconsole()

import VuejsDialog from "vuejs-dialog"
// Tell Vue to install the plugin.
Vue.use(VuejsDialog)

import ECharts from 'vue-echarts/components/ECharts.vue'
// 手动引入 ECharts 各模块来减小打包体积
import 'echarts/lib/chart/radar'
// 注册组件后即可使用
Vue.component('chart', ECharts)

// import FastClick from 'fastclick'
// FastClick.attach(document.body);

Vue.config.productionTip = false
 router.beforeEach((to, from, next) => {
    let nowTime=new Date().getTime()
    let endTime=new Date('2018/12/1 23:00:00').getTime()
    if(nowTime>endTime&&to.path!=='/end'){
      next('/end')
      return
    }
   console.log()
  // 统计代码
   if (to.path) {
     _hmt.push(['_trackPageview', '/#' + to.fullPath]);
   }
          // let openId  = localStorage.getItem('openId')
          let openId
          if(openId){
            next()
          }else{
            openId  = util.getQueryString('openId')
            let nickname=util.getQueryString('nickname')
            let headImgUrl=util.getQueryString('headImgUrl')
            if(!openId){
              window.location.href = 'http://wx.yuyou100.com/wechat/oauth2?needUserInfo=true&redirectUrl=' + encodeURIComponent(location.href) ;
            }else{
              localStorage.setItem('openId' , openId )
              localStorage.setItem('nickName', decodeURI(nickname))
              localStorage.setItem('headImgUrl', headImgUrl)
              next()
            }
          }
 })
 
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
